package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.ListenSpeakListDataBean;
import com.fancy.learncenter.ui.activity.EveryDayWorkActivity;
import com.fancy.learncenter.ui.activity.ExpandWorkActivity;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;
import com.fancy.learncenter.utils.TimeUtil;

import java.util.List;
import java.util.logging.LogRecord;

import cn.fanrunqi.waveprogress.WaveProgressView;

/**
 * Created by shiweiwei on 2017/12/6.
 */

public class EverydayListenSpeekAdapter extends CommonRecycleViewAdapter<ListenSpeakListDataBean.ResultBean> {
    private int progress;
    String filePath;

    public EverydayListenSpeekAdapter(Context mContext, List<ListenSpeakListDataBean.ResultBean> itemDatas, String filePath) {
        super(mContext, R.layout.everyday_listen_speek_item, itemDatas);
        this.filePath = filePath;
    }


    @Override
    public void bindView(CustomViewHold customViewHold, final ListenSpeakListDataBean.ResultBean item, int position) {
        ImageView lock_image = customViewHold.getView(R.id.lock_image);
        lock_image.setVisibility(View.GONE);
        ImageView downloac_image = customViewHold.getView(R.id.downloac_image);
        ImageView luo_icon = customViewHold.getView(R.id.luo_icon);


        TextView unit_num = customViewHold.getView(R.id.unit_num);
        unit_num.setText(item.getUnitName());

        TextView luo_num = customViewHold.getView(R.id.luo_num);

        TextView unit_text = customViewHold.getView(R.id.unit_text);
        unit_text.setText(item.getUnitName());


        LinearLayout luo_ll = customViewHold.getView(R.id.luo_ll);


        if (item.getIsLock().equals("1")) {
            lock_image.setVisibility(View.VISIBLE);
        } else {
            lock_image.setVisibility(View.GONE);
            luo_ll.setVisibility(View.VISIBLE);


            if (((int) item.getRadishCount()) == 0) {
                luo_icon.setImageResource(R.mipmap.cartoon_finish_work_turnip_gray);
            } else {
                luo_icon.setImageResource(R.mipmap.cartoon_finish_work_turnip_light);
            }

            luo_num.setText(((int) item.getRadishCount()) + "");

            customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, EveryDayWorkActivity.class);
//                    Intent intent = new Intent(mContext, ExpandWorkActivity.class);
                    intent.putExtra(EveryDayWorkActivity.PACKAGE_ID, item.getSpeakPackageId());
                    intent.putExtra(EveryDayWorkActivity.PACKAGE_RESOURCEPATH, filePath);
                    mContext.startActivity(intent);
                }
            });

        }

    }
}
